-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RHEL-13375: 1.28 Parse URL properly #3345
Conversation
d68fed0
to
ecb8f7c
Compare
I believe that this branch can be reviewed as it is and other changes related to IPv6 could introduced in other PRs later, but please do not merge this PR to 1.28 branch ATM. |
Since all the issues that happened after #3302 was merged were identified and fixed, would you please add the backports of the following PRs to this:
Thanks! |
Also, the issue reference needs to be changed to |
bf88151
to
112dd63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the backport. It seems mostly OK, there are few differences/changes:
-
in the commit "RHEL-13375: 1.28 Parse URL properly":
Two test cases were not backported:TestParseUrl.test_ipv4_url
TestParseUrl.test_ipv6_url
One test was moved from this commit to a later one, "Use username and password from --proxy=URL":TestOverrideCommand.test_proxy_user_and_pass_from_url_overridden_by_cli_options
-
in the commit "Improved printing of addresses and URLs"
There is one change missing:log.debug("Unable to get valid response: %s from CDN: %s" % (result, self.host))
(
self.host
was not wrapped usingnormalized_host()
)
112dd63
to
85d30ee
Compare
The PR is updated. |
* Backport to 1.28 branch * Original commit: e83e637 * Old tracking number for Bugzilla: 2225403 * Allow parsing of URLs containing IPv6 address like http://user:pass@[2001:db8::dead:beef:1]:3128/prefix * Use properties of urllib.parse to get username, password, hostname, port and prefix * Fixed unit tests for the case "https://www.redhat.com:/en", because it is IMHO correct URL * Extended unit tests related to parse_url().
* When URL in --proxy=URL contains username and password (e.g. --proxy=https://user:[email protected]:3128), then user and pass are used as proxy_user and proxy_pass * The --proxyuser and --proxypassword have higher priority. Thus, it does not break backward compatibility. * Added one unit test for this case
* Print IPv6 addresses correctly * Improved printing of proxy URL in debug mode
Use the existing helper to provide a properly formatted hostname for user displaying (e.g. for exception); this will fix the printing of IPv6 addresses. Turn the existing "host" member as property, so the current users keep working as expected.
Normalize the hostname printed for connection errors when pinging the server, in case anything was passed via --serverurl, --insecure, or --baseurl.
* Card ID: CCT-10 Recent changes (e83e637) fixed parsing information from IPv6 URLs. This patch fixes writing these addresses back as strings, mainly into configuration files. Previously, passing in IPv6 URL in e.g. `--baseurl` during registration resulted in broken address in the config file: $ subscription-manager register --baseurl https://[::1]:8443/prefix $ cat /etc/rhsm/rhsm.conf | grep baseurl baseurl=https://::1:8443/prefix After this patch, the square brackets are written when port is specified: $ cat /etc/rhsm/rhsm.conf | grep baseurl baseurl=https://[::1]:8443/prefix Due to the state of the code, it is likely that this problem also exists in other parts. If that is true, it is most likely in less sensitive parts, such as during logging. Looking back, using `ipaddress` stdlib would have been the right way to do this, but it is too late to do that.
* When --proxy is used, then try to ping server before new configuration is used.
85d30ee
to
a79a051
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
--proxy
CLI option to use parse_url() function